package particles;

import haxe.Timer;

class ParticlesJS
{
	var renderer : CanvasParticleRenderer;
	var engine : Engine; 
	
	public static function main()
	{
		try
		{
			new ParticlesJS();
		}
		catch (e : Dynamic)
		{
			trace("Error launching: " + e);
		}
	}
	
	public function new()
	{
		engine = new Engine(300);
		renderer = new CanvasParticleRenderer(engine.model);
		
		var timer = new Timer(Std.int(1000 / 30));
		timer.run = handleTimer;
	}
	
	function handleTimer()
	{
		engine.update();
		renderer.render();
	}
}
